package com.by.sbdemoby.utils;

import com.by.sbdemoby.model.AjaxResult;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpStatus;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @auth wzy
 * @date 2023/12/9 11:36
 */
public class ResponseUtils {

    public static void out(HttpServletResponse response, AjaxResult ajaxResult) {
        ObjectMapper mapper = new ObjectMapper();
        response.setStatus(HttpStatus.OK.value());
        response.setContentType("application/json;charset=UTF-8");
        try {
            mapper.writeValue(response.getWriter(), ajaxResult);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
